package com.lrd.snapshotorder.service.rule;

import com.lrd.snapshotorder.protocol.dto.order.OrderTaskCreateDto;

public abstract class AbstractRule implements IRule {

    @Override
    public boolean verify(OrderTaskCreateDto orderTaskCreateDto) {
        if ("numeric".equals(orderTaskCreateDto.getScene())) {
            if (orderTaskCreateDto.getDefaultAmount() == null) {
                throw new RuntimeException("固定金额模式下固定金额不能为空");
            }
        }
        if ("range".equals(orderTaskCreateDto.getScene())) {
            if (orderTaskCreateDto.getMinAmount() == null || orderTaskCreateDto.getMaxAmount() == null) {
                throw new RuntimeException("范围金额模式下金额上下限不能为空");
            }
        }
        return true;
    }
}
